﻿using System;
using System.ComponentModel;
using System.Windows;
using System.Data; 
using ReflectionStudio.Core.Events; 
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for EditEventWindow.xaml
    /// </summary>
    public partial class TVKQC 
    {

        ITXEXRPT ITXEXRPT;
        public TVKQC()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VVKPOS();
            this.DataContext = MV;
            MESSAGES += "VKKNEW;VVRELOAD;VVTCHG;VKPCHK;WDCHG;"; 
            InitializeComponent(); 
           
        }
      
        public override void Window_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            base.Window_Loaded(sender, e);
           
        }
      
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
           // base.vwMaster_CurrentChanged(sender, e);
           
        }

        public override void QueryCommand(object sender, System.Windows.RoutedEventArgs e)
        {
             
            dwData = TBMain.NewRow(); 
            dwData["VKPART"] = ART.Trim(); 
            try
            {
            SResult = TMV.QVKP27(dwData);
            MergeData(SResult, false);
            base.QueryCommand(sender, e);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        
        }
        private void btnSendToExcel_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (ITXEXRPT == null)
                {
                    ITXEXRPT = new ITXEXRPT();
                    ITXEXRPT.Root = "C:\\IntexReport";
                    ITXEXRPT.strCompany = app.company;
                    ITXEXRPT.PrintType = "OpenExcel";
                }
                ITXEXRPT.dsSource = new DataSet();
                ITXEXRPT.dsSource.Merge(MV.SetProd);
                //ITXEXRPT.dsSource.Merge(Se.Env);

                ITXEXRPT.DocType = "JLTVKQC";

                ITXEXRPT.strExcelFile = @"JLT\JLTVKQC.xls";
                string filename = ITXEXRPT.WriteExcelReport();
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        
    }
}
